package com.hiquety.tcb.listener;

import com.hiquety.tcb.entity.ClipboardItem;
import com.hiquety.tcb.ui.IndexUI;
import javafx.application.Platform;
import javafx.collections.ObservableList;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
import java.util.Map;

public class CenterBtnClickListener implements ActionListener {
    @Override
    public void actionPerformed(ActionEvent e) {
        Map<String, Long> map = new HashMap<>();
        Platform.runLater(() -> {
            ObservableList<ClipboardItem> list = IndexUI.observableList;
            for (ClipboardItem item : list) {
                int y = item.getCreateTime().getYear();
                int m = item.getCreateTime().getMonthValue();
                int d = item.getCreateTime().getDayOfMonth();
                String k = y + "-" + m + "-"+d;
                Long count;
                count = map.get(k) == null ? 0L : map.get(k);
                count++;
                map.put(k, count);
            }
            System.out.println(map);
        });

        String s = IndexUI.observableList.toString();
        int length = s.getBytes().length;
        System.out.println(length);
    }
}
